package com.woniuxy.juc.reentrant;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.LockSupport;

/**
 * <P> @Author: ideaAdmin
 * <P> TODO: Class
 * <P> TODO: 同步模式之顺序控制 LockSupport实现
 * <P> Date: 2022/4/8:8:48
 * <P> Description:
 */
@Slf4j(topic = "c.ReentrantLockTest8")
@SuppressWarnings(value = "all")
public class ReentrantLockTest8 {

    /**
     * TODO t2是否运行过
     */
    static boolean t2Runned = false;

    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            while (!t2Runned) {
                LockSupport.park();
                log.debug("1");
            }

        }, "t1");

        Thread t2 = new Thread(() -> {
                log.debug("2");
                t2Runned = true;
                LockSupport.unpark(t1);
        }, "t2");


        t1.start();
        t2.start();
    }
}
